package com.rao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rao.entity.User;
import com.rao.mapper.UserMapper;
import com.rao.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RestController;


import javax.annotation.Resource;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author rao3030
 * @since 2021-09-27
 */
@RestController
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Resource
    UserMapper userMapper;
    @Autowired
    JdbcTemplate jdbcTemplate;

    /**
     * @param username 表单账号
     * @return
     */
    @Override
    public User queryByUsername(String username) {
        //不想写SQL语句
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.lambda().eq(User::getUsername, username).eq(User::getDeleted, 0);
        return userMapper.selectOne(userQueryWrapper);
    }

}
